﻿using System;

using System.Collections.Generic;
using System.Text;
using Silvermoon.Controls;
using System.Drawing;
using Silvermoon.Utils;
using Silvermoon.OpenGL;
using Silvermoon.Shapes;
using Silvermoon;
using Silvermoon.Animations;

using Silvermoon.Controls.Base;
using Silvermoon.Images;
using Silvermoon.Windows;
using Silvermoon.UI;

namespace FileExplorer
{

    public class CalcButton : Button
    {
        private readonly Color glowColor = Color.FromArgb(20, 172, 255);
        private RotateTransform rotate;
        private TranslateTransform translate;
        private Color origColor;
        private Color origTextColor;
        //  private Animation animation;


        public CalcButton()
            : base()
        {
            translate = new TranslateTransform();
            rotate = new RotateTransform { Axis = RotateAxis.XAxis, Angle = 0f };
            //this.Label.Transformations = new Transformation[] { new TranslateTransform { Z = 5f } };

            Transformation += translate;
            Transformation += rotate;
            this.Background = new AccentShape();
        }

        static CalcButton()
        {
            var manager = new VisualStateManager(
                new VisualState(VState.Normal, 900),
                new VisualState(VState.Pressed,
                    new ColorTransition
                    {
                        Duration = 1,
                        To = Color.FromArgb(30, 183, 255),
                    }
                )
             );
            VisualStateManager.RegisterClassManager(typeof(CalcButton), manager);
        }

        public int WaveOffset { get; set; }

        public float ZOffset
        {
            get { return translate.Z; }
            set
            {
                if (translate.Z != value)
                {
                    translate.Z = value;
                    Invalidate(InvalidationFlag.Appearance);
                }
            }
        }

        protected float XAngle
        {
            get { return rotate.Angle; }
            set
            {
                rotate.Angle = value; Invalidate(InvalidationFlag.Appearance);
            }
        }

        protected override void OnPressedChanged()
        {
            if (origColor.IsEmpty) origColor = Color;
            if (origTextColor.IsEmpty) origTextColor = TextColor;
            base.OnPressedChanged();
            TextColor = IsPressed ? Color.White : origTextColor;
        }
    }
}
